package cn.matezk.lianlian.beans;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.Data;

import java.util.Calendar;
import java.util.Date;

@Data
public class LabelPrintParams {
    private String productId;
    private String deviceName;
    private Integer flowPkg;
    private String appKey;

    private String iccid;

    private Integer amount;
    private Date expireDate;

    public String getDeviceId() {
        return productId.concat("/").concat(deviceName);
    }

    public Date getExpireDate() {
        if (ObjectUtil.isNotNull(expireDate))   return expireDate;
        if (flowPkg.intValue() == 0)
            return DateUtil.parseDate("3000-01-01");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.YEAR, flowPkg);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.add(Calendar.DATE, -1);
        calendar.add(Calendar.MONTH, 2);
        return calendar.getTime();
    }
}
